package com.example.demo.controller;


import com.example.demo.model.ChatHistory;
import com.example.demo.service.IChatHistoryService;
import com.example.demo.vo.PageVo;
import com.example.demo.vo.RestResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/history")
@Api(tags = "聊天记录接口")
public class ChatHistoryController {

    @Autowired
    private IChatHistoryService iChatHistoryService;


    @PostMapping("/add")
    @ApiOperation(value = "添加消息记录接口",notes = "")
    public RestResultVo<ChatHistory> add (@RequestBody ChatHistory chatHistory){
       ChatHistory add = iChatHistoryService.add(chatHistory);
        return RestResultVo.ok(add);
    }

    @GetMapping("/listChatHistory")
    @ApiOperation("查询历史聊天记录列表")
    public RestResultVo<PageVo<ChatHistory>>  listHistory(Integer pageNumber, Integer pageSize){
        PageVo<ChatHistory> pageVo = iChatHistoryService.listChatHistory(pageNumber,pageSize);
        return RestResultVo.ok(pageVo);
    }



}
